package com.hexorld.core;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;

import com.hexorld.utils.Constants;
import com.hexorld.utils.Coordinate;
import com.hexorld.utils.Position;
import com.hexorld.utils.Utils;

public class MapItem extends HVisualObject {
	public int type;
	public Object tag;
	public Coordinate coordinate;
	public boolean isOccupied;
	private int mapItemResId = 0;
	
	protected Bitmap mBitmap = null;
	public MapItem(Context context){
		super(context,0,0, new Position(0, 0));
		coordinate = Coordinate.createCoordinateByPos(this.position);
	}
	
	public MapItem(Context context, int x, int y, int z){
		super(context, Constants.POS_TO_COOR_X, Constants.POS_TO_COOR_Y, new Position(x* Constants.POS_TO_COOR_X, y * Constants.POS_TO_COOR_Y));
		coordinate = new Coordinate(x, y, z);
	}
	
	public void setResourceById(int resId){
		mapItemResId = resId;
		mBitmap = Utils.getBitmapByResId(mContext, mapItemResId);
	}
	
	public boolean canGoThrough(){
		return true;
	}

	public void draw(Canvas canvas) {
		if(canvas == null || mBitmap == null)
			return;
		mDstRect.left = getLeft();
		mDstRect.right = getRight();
		mDstRect.top = getTop();
		mDstRect.bottom = getBottom();
		canvas.drawBitmap(mBitmap, null, mDstRect, mPaint);
	}

	@Override
	public void update(long timeElapsed) {
		// TODO Auto-generated method stub
		
	}

}
